
package dto;

import java.util.ArrayList;


public class DTO_GioHang extends ArrayList<DTO_SanPham>{

    public void themSanPham(DTO_SanPham sp)
    {
        boolean flag = false;
        for(DTO_SanPham tempSP : this)
        {
            if(tempSP.getMaSP() == sp.getMaSP())
            {
                tempSP.setSoLuong(tempSP.getSoLuong()+1);
                flag = true;
                break;
            }
        }
        if(flag == false)
        {
            this.add(sp);
        }
    }
    public boolean xoaSanPham(int ID)
    {
        boolean flag = false;
        for(DTO_SanPham tempSP : this)
        {
            if(tempSP.getMaSP() == ID)
            {
                this.remove(tempSP);
                flag = true;
                break;
            }
        }
        return flag;

    }

   

}
